﻿#ifndef RESULTMANAGER_H
#define RESULTMANAGER_H

#include <singleton.h>
#include <QDateTime>
#include <QVector>

//#define RESULT_NUM 1
class ResultManager:public Singleton<ResultManager>
{
private:
    ResultManager();
protected:
    friend class Singleton<ResultManager>;
public:
	/**
	* Error code to handler
	*/
	typedef enum _ERROR_TYPE {
		ERR_PASS = 1,
		ERR_BALL_DAMAGE = 2,
		ERR_BALL_MISSING = 3,
		ERR_SUBSTRATE_DAMAGE = 4,
		ERR_CAP_DAMAGE = 5,
		ERR_CAP_MISSING = 6,
	//	ERR_CROSS_MARK = 7,
		ERR_WRONG_IMAGE = 7,
		ERR_PAD_DAMAGE = 8,
		ERR_MAX,
	}ERROR_TYPE;

    typedef struct _RESULT_DEF{
		QString people;
		QString product;
        QDateTime time;
        uint8_t result;
    }RESULT_DEF;

	typedef struct _VM_REMARK {
		int iBallDamage;
		int iSubstrateDamage;
		int iCrossMark;
		int iCap;
	}VM_REMARK;

	typedef struct _DATE_RESULT_DEF {
		int total;
		int ok;
		int ng;
		VM_REMARK mark;
        QString version;
	}DATE_RESULT_DEF;

    QVector<ResultManager::RESULT_DEF> ParseLogFile(QString filePath);
    void SaveResultToLogFile(QString filePath, ResultManager::RESULT_DEF res);
	QMap<QString, ResultManager::DATE_RESULT_DEF> LogsByDate(QString filePath);
};

#endif // RESULTMANAGER_H
